from selenium.webdriver.common.by import By

from common.Utils import BlogDriver

#博客首页测试用例
class BlogList:
    url=""
    driver=""
    def __init__(self):
        self.driver=BlogDriver.driver
        self.url="http://8.137.19.140:9090/blog_list.html"
        self.driver.get(self.url)

    #前提:登录状态下才能进入列表页
    def ListTestByLogin(self):
        #标题
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.title")
        #内容
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div:nth-child(1) > div.desc")
        #全文按键
        articles=self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div:nth-child(1) > a")
        #个人信息--昵称
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.left > div > h3").click()

        BlogDriver.getScreeShot()

        # 测试首页 - 未登录的情况下 - 跳转到登录页面
        # 上面的代码执行完成后是登录页面，所以我们要点就注销按钮，达到未登录的状态
    def ListTestByFileLogin(self):
        #点击注销按钮
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(6)").click()
        #登录
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container-login > div > h3")
        #用户名
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container-login > div > div:nth-child(2) > span")
        #密码
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container-login > div > div:nth-child(3) > span")
        #提交
        self.driver.find_element(By.CSS_SELECTOR,"#submit")
        BlogDriver.getScreeShot()

# list=BlogList()